from flask import Flask
from flask import request
from newDataFit.main import getNewLocations

app = Flask(__name__)  # 创建1个Flask实例


@app.route('/fit', methods=['POST'])  # 路由系统生成 视图对应url,1. decorator=app.route() 2. decorator(first_flask)
def first_flask():  # 视图函数
    jbody = request.get_json()
    nation = jbody['nation']
    columnName = jbody['columnName']
    newValue = jbody['newValue']
    locations,values = getNewLocations(nation, columnName, newValue)
    return {"locations": locations,'values':values}  # response


if __name__ == '__main__':
    app.run()  # 启动socket
